﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using System.Web;
using Antu.WorkFlowFactory;
using System.Data;

namespace WebSys.UI.OfficeFlow
{
    public class InstanceSearchOneSkin : MPBasicTemplate
    {
        FlowFactoryProvider _FlowFactoryProvider = (FlowFactoryProvider)ProviderService.ProviderServiceMange.GetProvider("FlowFactoryProvider");
        string iid;
        Label iidlab, flowtypelab, statuslab;
        MPRepeater showsearchone;
        protected override void OnLoad(EventArgs e)
        {
            string strIId = base.Page.Request["IID"];
            if (!string.IsNullOrEmpty(strIId))
            {
                LoginHelper.CheckLogin();
                InitControl();
                base.OnLoad(e);
                if (!base.Page.IsPostBack)
                {
                    Initcy();
                }
            }
            else {
                Antu.Utilities.UtilitiesPage.AlertDialog("没有该流程详情！", "window.close();");
            }
            
            
        }

        private void InitControl()
        {
            iid = Antu.Utilities.UtilitiesPage.GetStringPar("iid", "");
            showsearchone = (MPRepeater)FindControl("showsearchone");
            iidlab = (Label)FindControl("iidlab");
            flowtypelab = (Label)FindControl("flowtypelab");
            statuslab = (Label)FindControl("statuslab");
            
        }


        private void Initcy()
        {

            if (!string.IsNullOrEmpty(iid))
            {
                string query = "";
                if (!string.IsNullOrEmpty(iid))
                {
                    query += " and i.iid='" + iid + "' ";
                }
                DataTable instancedt = _FlowFactoryProvider.GetUserRightWorkFlow(query);
                if (instancedt.Rows.Count > 0)
                {
                    iidlab.Text = instancedt.Rows[0]["iid"].ToString();
                    flowtypelab.Text = instancedt.Rows[0]["wname"].ToString();
                    if (instancedt.Rows[0]["status"].ToString() == "1")
                    {
                        statuslab.Text = "办理中";
                    }
                    else if (instancedt.Rows[0]["status"].ToString() == "2")
                    {
                        statuslab.Text = "办结";
                    }
                    else if (instancedt.Rows[0]["status"].ToString() == "0")
                    {
                        statuslab.Text = "挂起";
                    }
                    else if (instancedt.Rows[0]["status"].ToString() == "-1")
                    {
                        statuslab.Text = "中止";
                    }

                }
                DataTable dt = _FlowFactoryProvider.GetUserRightWorkFlowStepByStep(iid);
                showsearchone.DataSource = dt;
                showsearchone.DataBind();
            }
        }


    }
}


